/**
* 左边菜单
*/
<template>
  <el-menu :default-active="$route.path" :collapse="collapsed" collapse-transition router unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuid">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    let res = {
      success: true,
      data: [
        {
          menuid: "1",
          icon: 'li-icon-xiangmuguanli',
          menuname: '基础管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: "2",
              icon: 'icon-cat-skuQuery',
              menuname: '考证活动列表',
              hasThird: 'N',
              url: 'activity/list',
              menus: null
            },
            {
              menuid: "3",
              icon: 'icon-cs-manage',
              menuname: '报名列表',
              hasThird: 'N',
              url: 'activity/applicationList',
              menus: null
            },
            {
              menuid: "4",
              icon: 'icon-order-manage',
              menuname: '题库列表',
              hasThird: 'N',
              url: 'question/list',
              menus: null
            }
          ]
        }, {
          menuid: "10",
          icon: 'li-icon-xiangmuguanli',
          menuname: '证书管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: "11",
              icon: 'icon-cms-manage',
              menuname: '成绩证明',
              hasThird: 'N',
              url: 'certificate/list?type=grade',
              menus: null
            },
            {
              menuid: "12",
              icon: 'icon-cs-manage',
              menuname: '等级证书',
              hasThird: 'N',
              url: 'certificate/list?type=academic',
              menus: null
            }
          ]
        }, {
          menuid: "30",
          icon: 'li-icon-xiangmuguanli',
          menuname: '账号管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: "31",
              icon: 'icon-cs-manage',
              menuname: '用户列表',
              hasThird: 'N',
              url: 'user/list',
              menus: null
            }
          ]
        }, {
          menuid: "20",
          icon: 'li-icon-xiangmuguanli',
          menuname: '工具管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: "21",
              icon: 'icon-cs-manage',
              menuname: '上传图片接口',
              hasThird: 'N',
              url: 'img/upload',
              menus: null
            }
          ]
        }
      ],
      msg: 'success'
    }
    this.allmenu = res.data
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 40px;
}
</style>
